home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Just Call Me Internet
/
Just Call Me Internet.iso
/
prog
/
atari
/
c
/
du_lib
/
proc_msg.c
< prev
next >
Wrap
C/C++ Source or Header
|
1995-07-10
|
11KB
|
415 lines
/*
DU_LIB v2
Gem Window Management & Dialog Library For Lattice C
½1994,95, by Craig Graham.
Based on the DU_LIBv1 Library for HiSoft Basic.
*/
/*
GEM AES message handler
*/
#include "dulib.h"
event process_message(short mb[])
{
short m,arrow_m,x,y,w,h;
short e_wind;
OBJECT *a_l;
short sx,sy,sw,sh;
short a,b;
CallBack custom_handler;
window_widget_response widget_callbacks;
CallBack widget_handler;
event ret_v;
Wtype t;
ret_v=0;
a_l=0;
e_wind=mb[3]; /*Window for which the message arrived*/
m=mb[0]; /*Message type*/
if (!xacc_message(mb))
{
if (m==MN_SELECTED) /*Event was a menu*/
{
rsrc_gaddr(0,menu,&a_l);
custom_handler=Get_object_callback(menu, mb[4]); /*Check for a custom object handler*/
if (!custom_handler)
{
ret_v=Get_object_event(menu,mb[4]); /*Return menu item selected*/
menu_tnormal(a_l,e_wind,1);
}else{
this_dialog=menu; this_ob=mb[4];
(*custom_handler)(); /*Call a custom handler for that selection*/
menu_tnormal(a_l,e_wind,1);
}
} else {
if (windows[e_wind].window_type==wt_null) return ret_v;
this_dialog=windows[e_wind].the_dialog;
cr_wind_handle=e_wind;
widget_callbacks=dialog_details[windows[e_wind].the_dialog].wind_widgets;
switch(m) /*Common messages for all window types*/
{
/*Xacc2 support*/
case ACC_TEXT: /*Recieve Text*/
if (XaccTextHandler)
{
if ((*XaccTextHandler)())
{
xacc_ack( mb[1], TRUE );
}else{
xacc_ack( mb[1], FALSE );
}
}else{
xacc_ack( mb[1], FALSE );
}
break;
case WM_CLOSED:
widget_handler=widget_callbacks.close_widget;
if (widget_handler)
{
(*widget_handler)();
}else{
close_dialog_window(e_wind);
}
break;
case WM_TOPPED:
wind_get(e_wind,WF_TOP,&a,0,0,0);
if (a==e_wind)
{
wind_set(e_wind,WF_BOTTOM,0,0,0,0);
} else {
wind_set(e_wind,WF_TOP,0,0,0,0);
}
ret_v=3;
break;
case WM_BOTTOMED:
wind_set(e_wind,WF_BOTTOM,0,0,0,0);
break;
case WM_UNTOPPED:
break;
case WM_REDRAW:
udx=mb[4]; udy=mb[5];
udw=mb[6]; udh=mb[7];
redraw_window(e_wind);
break;
case WM_CUSTOM_REDRAW:
udx=mb[4]; udy=mb[5];
udw=mb[6]; udh=mb[7];
custom_redraw_window(e_wind);
break;
case WM_HSLID:
wind_set(e_wind,WF_HSLIDE,mb[4],0,0,0);
widget_handler=widget_callbacks.h_slide;
if (widget_handler)
{
(*widget_handler)();
}else{
if (windows[e_wind].redraw_mode==wrm_window)
{
if (windows[e_wind].window_type==wt_drawing)
{
custom_update_window(e_wind);
}else{
update_window(e_wind);
}
}
}
break;
case WM_VSLID:
wind_set(e_wind,WF_VSLIDE,mb[4],0,0,0);
widget_handler=widget_callbacks.v_slide;
if (widget_handler)
{
(*widget_handler)();
}else{
if (windows[e_wind].redraw_mode==wrm_window)
{
if (windows[e_wind].window_type==wt_drawing)
{
custom_update_window(e_wind);
}else{
update_window(e_wind);
}
}
}
break;
case WM_ICONIFY:
widget_handler=widget_callbacks.iconify_widget;
if (widget_handler)
{
(*widget_handler)();
}else{
wind_get(e_wind,WF_CURRXYWH,&sx,&sy,&sw,&sh);
wind_set(e_wind,WF_ICONIFY,0,0,0,0);
wind_set(e_wind,WF_CURRXYWH,mb[4],mb[5],mb[6],mb[7]);
}
break;
case WM_ARROWED:
arrow_m=mb[4];
widget_handler=widget_callbacks.arrows[arrow_m];
if (widget_handler)
{
(*widget_handler)();
}else{
arrow_m|=128;
switch(arrow_m)
{
case WIDGET_ARROW_UPPAGE:
wind_get(e_wind,WF_VSLIDE,&a,0,0,0);
a-=100;
if (a<0) a=0;
wind_set(e_wind,WF_VSLIDE,a,0,0,0);
break;
case WIDGET_ARROW_DNPAGE:
wind_get(e_wind,WF_VSLIDE,&a,0,0,0);
a+=100;
if (a>1000) a=1000;
wind_set(e_wind,WF_VSLIDE,a,0,0,0);
break;
case WIDGET_ARROW_UPLINE:
wind_get(e_wind,WF_VSLIDE,&a,0,0,0);
a-=5;
if (a<0) a=0;
wind_set(e_wind,WF_VSLIDE,a,0,0,0);
break;
case WIDGET_ARROW_DNLINE:
wind_get(e_wind,WF_VSLIDE,&a,0,0,0);
a+=5;
if (a>1000) a=1000;
wind_set(e_wind,WF_VSLIDE,a,0,0,0);
break;
case WIDGET_ARROW_LFPAGE:
wind_get(e_wind,WF_HSLIDE,&a,0,0,0);
a-=100;
if (a<0) a=0;
wind_set(e_wind,WF_HSLIDE,a,0,0,0);
break;
case WIDGET_ARROW_RTPAGE:
wind_get(e_wind,WF_HSLIDE,&a,0,0,0);
a+=100;
if (a>1000) a=1000;
wind_set(e_wind,WF_HSLIDE,a,0,0,0);
break;
case WIDGET_ARROW_LFLINE:
wind_get(e_wind,WF_HSLIDE,&a,0,0,0);
a-=5;
if (a<0) a=0;
wind_set(e_wind,WF_HSLIDE,a,0,0,0);
break;
case WIDGET_ARROW_RTLINE:
wind_get(e_wind,WF_HSLIDE,&a,0,0,0);
a+=5;
if (a>1000) a=1000;
wind_set(e_wind,WF_HSLIDE,a,0,0,0);
break;
}
if (windows[e_wind].window_type==wt_drawing)
{
custom_update_window(e_wind);
}else{
update_window(e_wind);
}
}
break;
}
t=windows[e_wind].window_type; /* Type of window we are looking at */
switch(t)
{
case wt_dialog:
case wt_dialog_side_bar:
case wt_dialog_bottom_bar:
switch(m)
{
case WM_FULLED: /*With Dialog Windows, make them Roll-Ups*/
widget_handler=widget_callbacks.full_widget;
if (widget_handler)
{
(*widget_handler)();
}else{
wind_get(e_wind,WF_WORKXYWH,&sx,&sy,&sw,&sh);
if (sh)
{
sh=0;
} else {
rsrc_gaddr(0,windows[e_wind].the_dialog,&a_l);
form_center(a_l,&a,&b,&sw,&sh);
}
switch(t)
{
case wt_dialog:
wind_calc(WC_BORDER,NAME+CLOSER+FULLER+MOVER+SMALLER,sx,sy,sw,sh,&sx,&sy,&sw,&sh);
break;
case wt_dialog_side_bar:
wind_calc(WC_BORDER,NAME+CLOSER+FULLER+MOVER+UPARROW+DNARROW+VSLIDE+SMALLER,sx,sy,sw,sh,&sx,&sy,&sw,&sh);
break;
case wt_dialog_bottom_bar:
wind_calc(WC_BORDER,NAME+CLOSER+FULLER+MOVER+LFARROW+RTARROW+HSLIDE+SMALLER,sx,sy,sw,sh,&sx,&sy,&sw,&sh);
break;
}
wind_set(e_wind,WF_CURRXYWH,sx,sy,sw,sh);
}
break;
case WM_MOVED:
if (mb[4]<0) { mb[4]=0; }
wind_set(e_wind,WF_CURRXYWH,mb[4],mb[5],mb[6],mb[7]);
rsrc_gaddr(0,windows[e_wind].the_dialog,&a_l);
wind_get(e_wind,WF_WORKXYWH,&x,&y,&w,&h);
if (h!=0)
{
a_l->ob_x=x;
a_l->ob_y=y;
}
break;
case WM_UNICONIFY:
wind_set(e_wind,WF_UNICONIFY,0,0,0,0);
rsrc_gaddr(0,windows[e_wind].the_dialog,&a_l);
form_center(a_l,&sx,&sy,&sw,&sh);
wind_calc(0,15,sx,sy,sw,sh,&sx,&sy,&sw,&sh);
wind_set(e_wind,WF_CURRXYWH,sx,sy,sw,sh);
break;
}
break;
case wt_drawing:
switch(m)
{
case WM_FULLED: /*With drawing (ie. work area/widget bar) Windows, make them full/shrink */
widget_handler=widget_callbacks.full_widget;
if (widget_handler)
{
(*widget_handler)();
}else{
wind_get(e_wind,WF_CURRXYWH,&sx,&sy,&sw,&sh);
wind_get(e_wind,WF_FULLXYWH,&x,&y,&w,&h);
if ((((sx!=x)||(sy!=y))||(sw!=w))||(sh!=h))
{
wind_set(e_wind,WF_CURRXYWH,x,y,w,h);
}else{
wind_get(e_wind,WF_PREVXYWH,&x,&y,&w,&h);
wind_set(e_wind,WF_CURRXYWH,x,y,w,h);
}
rsrc_gaddr(0,windows[e_wind].the_dialog,&a_l);
wind_get(e_wind,WF_WORKXYWH,&x,&y,&w,&h);
if (h!=0)
{
a_l->ob_x=x;
a_l->ob_y=y;
}
}
break;
case WM_MOVED:
if (mb[4]<0) { mb[4]=0; }
wind_set(e_wind,WF_CURRXYWH,mb[4],mb[5],mb[6],mb[7]);
rsrc_gaddr(0,windows[e_wind].the_dialog,&a_l);
wind_get(e_wind,WF_WORKXYWH,&x,&y,&w,&h);
if (h!=0)
{
a_l->ob_x=x;
a_l->ob_y=y;
}
break;
case WM_SIZED:
widget_handler=widget_callbacks.resize_widget;
if (widget_handler)
{
(*widget_handler)();
}else{
if (mb[4]<0) { mb[4]=0; }
wind_set(e_wind,WF_CURRXYWH,mb[4],mb[5],mb[6],mb[7]);
rsrc_gaddr(0,windows[e_wind].the_dialog,&a_l);
wind_get(e_wind,WF_WORKXYWH,&x,&y,&w,&h);
if (h!=0)
{
a_l->ob_x=x;
a_l->ob_y=y;
}
}
break;
case WM_UNICONIFY:
wind_get(e_wind,WF_UNICONIFYXYWH,&sx,&sy,&sw,&sh);
wind_set(e_wind,WF_UNICONIFY,0,0,0,0);
wind_get(e_wind,WF_CURRXYWH,&sx,&sy,&sw,&sh);
wind_get(e_wind,WF_FULLXYWH,&x,&y,&w,&h);
if ((((sx!=x)||(sy!=y))||(sw!=w))||(sh!=h))
{
wind_set(e_wind,WF_CURRXYWH,x,y,w,h);
}else{
wind_get(e_wind,WF_PREVXYWH,&x,&y,&w,&h);
wind_set(e_wind,WF_CURRXYWH,x,y,w,h);
}
rsrc_gaddr(0,windows[e_wind].the_dialog,&a_l);
wind_get(e_wind,WF_WORKXYWH,&x,&y,&w,&h);
if (h!=0)
{
a_l->ob_x=x;
a_l->ob_y=y;
}
break;
}
break;
}
}
}
return ret_v;
}
short redraw_window(short wind_handle)
{
wind_update(BEG_UPDATE);
display_dial(wind_handle);
wind_update(END_UPDATE);
udx=udy=udw=udh=0 ;
return 0;
}
short custom_redraw_window(short wind_handle)
{
wind_update(BEG_UPDATE);
custom_display_dial(wind_handle);
wind_update(END_UPDATE);
udx=udy=udw=udh=0 ;
return 0;
}
/*
Set the widget callback for a given dialog
*/
void Set_dialog_widget_callback(short dialog, short widget, CallBack c)
{
if (!(widget&128))
{
switch(widget)
{
case WIDGET_CLOSE:
dialog_details[dialog].wind_widgets.close_widget=c;
break;
case WIDGET_FULL:
dialog_details[dialog].wind_widgets.full_widget=c;
break;
case WIDGET_ICONIFY:
dialog_details[dialog].wind_widgets.iconify_widget=c;
break;
case WIDGET_RESIZE:
dialog_details[dialog].wind_widgets.resize_widget=c;
break;
case WIDGET_H_SLIDE:
dialog_details[dialog].wind_widgets.h_slide=c;
break;
case WIDGET_V_SLIDE:
dialog_details[dialog].wind_widgets.v_slide=c;
break;
}
}else{
dialog_details[dialog].wind_widgets.arrows[widget&~128]=c;
}
}